function [DI rhoMI rhoDI]=DirectedInformation(X,Y)
MI1=0;
CMI1=0;
N=length(X);
for i=1:N
MI1=MI1+mutualinfo(X(1:i,1),Y(1:i,1));
CMI1=CMI1+condentropy(X(1:i,1),Y(1:i,1));
end

x=X;
y=Y;
%x(1)=[];
y(N)=[];
y=[0 ;y];

MI0=0;
CMI0=0;
for i=1:N
MI0=MI0+mutualinfo(x(1:i,1),y(1:i,1));
CMI0=CMI0+condentropy(x(1:i,1),y(1:i,1));
end


MI=mutualinfo(X,Y);
%DI=MI1-MI0;
DI=CMI0-CMI1;
%rhoDI=sqrt(1-exp(-2*DI));
rhoMI=sqrt(1-exp(-2*MI));